//
//  TMBuyGoodsCell.m
//  国学商家管理
//
//  Created by Tao Li on 2018/7/6.
//  Copyright © 2018年 mac. All rights reserved.
//

#import "TMBuyGoodsCell.h"
#import "TMMyCourseModel.h"
@implementation TMBuyGoodsCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
    self.backView.layer.borderWidth = 1.0f;
    self.backView.layer.borderColor = [UIColor hx_colorWithHexRGBAString:@"#EEEEEE"].CGColor;
    self.courseImage.contentMode = UIViewContentModeScaleAspectFill;
    self.courseImage.clipsToBounds = YES;
}
- (void)setHasDiscount:(BOOL)hasDiscount{
    _hasDiscount = hasDiscount;
    if (_hasDiscount == NO) {
        self.noDiscountCount.constant = 0;
        self.discountLabel.hidden = YES;
        self.canUseBtn.hidden = YES;
        self.canUseImage.hidden = YES;
        self.lineView.hidden = YES;
    }else{
        //267 -50
        self.noDiscountCount.constant = 49.5;
        self.discountLabel.hidden = NO;
        self.canUseBtn.hidden = NO;
        self.canUseImage.hidden = NO;
        self.lineView.hidden = NO;
    }
}
-(void)setOrderModel:(TMMyCartModel *)orderModel{
    _orderModel = orderModel;
    self.nowPrice.text = nil;
    [self.courseImage sd_setImageWithURL:[NSURL URLWithString:[NSString stringWithBaseUrl:orderModel.pic[0]]] placeholderImage:kPlaceholder];
    self.courseDeatilLabel.text = orderModel.name;
    if (orderModel.rank >1) {
       self.beforePrice.text = [NSString stringWithFormat:@"折扣价:%.02f", orderModel.price];
        self.beforeMoneys.text = [NSString stringWithFormat:@"原价:%.02f", orderModel.money];
        self.linview.hidden = NO;
    }else{
        self.beforePrice.text = [NSString stringWithFormat:@"原价:%.02f", orderModel.money];
        self.beforeMoneys.hidden = YES;
        self.linview.hidden = YES;
    }
//    if (orderModel.nowMoney == 0) {
//        orderModel.nowMoney = orderModel.price;
//    }
    if (orderModel.nowMoney) {
        self.nowPrice.text = [NSString stringWithFormat:@"券后价:%.02f", orderModel.nowMoney];
    }
    self.totalLabel.text = @"数量：1";
}
- (IBAction)canUseBtnClick:(UIButton *)sender {
    if (self.disBlock) {
        self.disBlock();
    }
}
- (IBAction)cancelBtnClick:(UIButton *)sender {
    if (self.cancelBlock) {
        self.cancelBlock();
    }
}
- (IBAction)buyBtnClick:(UIButton *)sender {
    if (self.payBlock) {
        self.payBlock();
    }
}

@end
